
var dictutil = {
    /**
     * 字典请求
     * @param selectId select id
     * @param callback
     */
    getDictJson: function (dictType, callback) {
        layutil.get("/channel/sys-dict/get_dict_by_type", {code: dictType}, function (res) {
            if(typeof callback === 'function') {
                callback.call(this, res);
                return false;
            }
            var json = {};
        });
    },
    loadDict: function(dictType) {
        //localStorage.removeItem("dict_" + String(dictType));
        var item = localStorage.getItem("dict_" + String(dictType));
        if(item == null || item == undefined) {
            var url = "/channel/sys-dict/get_dict_by_type/" + String(dictType);
            layutil.get(url, null, function (res) {
                if (res.code == 0) {
                    localStorage.setItem("dict_" + String(dictType), JSON.stringify(res.data));
                }
            });
        }
    },
    getDictSpan: function (dictType, d) {
        var item = JSON.parse(localStorage.getItem("dict_" + String(dictType)));
        if(item == null || item == undefined) {
            return "";
        } else {
            for(var o in item) {
                if(item[o].code == d) {
                    var color = item[o].color;
                    if(color == null || color == undefined) color = "gray";
                    return "<span style='color: "+color+"'>"+item[o].tips+"</span>";
                }
            }
            return "";
        }
    },
    clearAllItem: function () {
        localStorage.clear();
    }
};